﻿using Coldairarrow.Business.Base;
using Coldairarrow.Entity.Base;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.Base
{
    [Route("/Base/[controller]/[action]")]
    public class Base_RepairOrderFileListController : BaseApiController
    {
        #region DI

        public Base_RepairOrderFileListController(IBase_RepairOrderFileListBusiness base_RepairOrderFileListBus)
        {
            _base_RepairOrderFileListBus = base_RepairOrderFileListBus;
        }

        IBase_RepairOrderFileListBusiness _base_RepairOrderFileListBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<Base_RepairOrderFileList>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _base_RepairOrderFileListBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<Base_RepairOrderFileList> GetTheData(IdInputDTO input)
        {
            return await _base_RepairOrderFileListBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(Base_RepairOrderFileList data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _base_RepairOrderFileListBus.AddDataAsync(data);
            }
            else
            {
                await _base_RepairOrderFileListBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _base_RepairOrderFileListBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}